package com.android.support.lib.universal.utils;

import android.content.Context;
import android.view.Gravity;
import android.view.LayoutInflater;
import android.view.View;
import android.widget.TextView;
import android.widget.Toast;

import com.android.support.lib.universal.R;
import com.android.support.lib.universal.base.BaseApplication;

/**
 * @author 彭治铭
 */
public class UtilToast {
    public static View getView(Context context, int layoutId) {
        LayoutInflater mInflater = LayoutInflater.from(context);
        View view = mInflater.inflate(layoutId, null);
        return view;
    }

    public static void showToastView(String text) {
        Toast toast = new Toast(BaseApplication.getInstance());
        toast.setGravity(Gravity.CENTER | Gravity.BOTTOM, 0, 310);// 显示位置
        toast.setDuration(Toast.LENGTH_LONG);// 显示时长，1000为1秒
        View view = getView(BaseApplication.getInstance(), R.layout.lib_toast);
        TextView textView = (TextView) view.findViewById(R.id.lib_tost_text);
        textView.setText(text);
        view.getBackground().setAlpha(150);// 设置透明的
        toast.setView(view);// 自定义view
        toast.show();
    }

}
